home *** CD-ROM | disk | FTP | other *** search
/ Freelog 46 / Freelog046.iso / Alu / Celestia / Win32LoresTex / celestia-lores-win32-1.3.0.exe / {app} / shaders / haze_arb.vp < prev    next >
Text File  |  2003-02-17  |  1KB  |  54 lines

  1. !!ARBvp1.0
  2.  
  3. # Compute the diffuse light from a single source and a haze effect
  4.  
  5. ATTRIB iPos          = vertex.position;
  6. ATTRIB iNormal       = vertex.normal;
  7. ATTRIB iTex0         = vertex.texcoord[0];
  8. PARAM  mvp[4]        = { state.matrix.mvp };
  9. PARAM  eyePos        = program.env[1];
  10. PARAM  lightDir      = program.env[0];
  11. PARAM  diffuse       = program.env[2];
  12. PARAM  ambient       = program.env[5];
  13. PARAM  zero          = 0;
  14. PARAM  one           = 1;
  15. OUTPUT oPos          = result.position;
  16. OUTPUT oColor        = result.color;
  17. OUTPUT oTex0         = result.texcoord[0];
  18. OUTPUT oFog          = result.fogcoord;
  19.  
  20. TEMP   diffuseFactor;
  21. TEMP   eyeVec;
  22.  
  23. # Transform the vertex by the modelview matrix
  24. DP4   oPos.x, mvp[0], iPos;
  25. DP4   oPos.y, mvp[1], iPos;
  26. DP4   oPos.z, mvp[2], iPos;
  27. DP4   oPos.w, mvp[3], iPos;
  28.  
  29. # Compute the diffuse light component
  30. DP3   diffuseFactor, iNormal, lightDir;
  31. # Clamp the diffuse component to zero
  32. MAX   diffuseFactor, diffuseFactor, zero;
  33.  
  34. # Get the vector from the eye to the vertex
  35. SUB   eyeVec, eyePos, iPos;
  36.  
  37. # Normalize it
  38. DP3   eyeVec.w, eyeVec, eyeVec;
  39. RSQ   eyeVec.w, eyeVec.w;
  40. MUL   eyeVec, eyeVec, eyeVec.w;
  41.  
  42. # Haze
  43. DP3   diffuseFactor.y, iNormal, eyeVec;
  44. SUB   diffuseFactor.y, one, diffuseFactor.y;
  45. MUL   oFog.x, diffuseFactor.x, diffuseFactor.y;
  46.  
  47. # Output the texture
  48. MOV   oTex0, iTex0;
  49. # Output the primary color
  50. MAD   oColor, diffuse, diffuseFactor.x, ambient;
  51.  
  52. END
  53.  
  54.